import java.io.ByteArrayInputStream;

import org.apache.log4j.BasicConfigurator;

import com.oneandone.httpserver.tcp.http.Server;
import com.oneandone.httpserver.tcp.http.request.HttpMethod;
import com.oneandone.httpserver.tcp.http.request.HttpRequest;
import com.oneandone.httpserver.tcp.http.response.HttpResponse;
import com.oneandone.httpserver.tcp.http.response.HttpStatus;
import com.oneandone.httpserver.tcp.http.route.RequestHandler;

public class Main {
	public static void main(String[] args) throws Exception {
//		BasicConfigurator.configure();
		Server s = Server.create().port(9090).keepAlive(false).workers(10)
				.route(HttpMethod.GET, "//*", new RequestHandler() {

					@Override
					public HttpResponse handle(HttpRequest request) {
//						String param = request.getParameters().get("test")
//								.get(0);
						String message = "This is Houston.We read you loud and clear.";
						return HttpResponse
								.status(HttpStatus.OK)
								.header("Content-Type", "plain/text")
								.body(new ByteArrayInputStream(message.getBytes()));
					}
				}).start();
//		Server s = Server.create().port(8080).keepAlive(false).workers(10).start();
		//wait for stop
		
		//s.stop();
		
	}
}
